<@>layout("/common/default.html"){
<link rel="stylesheet" href="${ctxPath}/static/zTree3.5/css/metroStyle/metroStyle.css" type="text/css">
<script type="text/javascript" src="${ctxPath}/static/zTree3.5/js/jquery.ztree.all.js"></script>
<script type="text/javascript" src="${ctxPath}/static/zTree3.5/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="${ctxPath}/static/zTree3.5/js/jquery.ztree.exedit.js"></script>
<script type="text/javascript" src="${ctxPath}/static/im/unit.js"></script>
<script type="text/javascript" src="${ctxPath}/static/im/message.js"></script>
<script type="text/javascript" src="${ctxPath}/static/im/messagebody.js"></script>
<script type='text/javascript' src='${ctxPath}/dwr/engine.js'></script>
<!-- 顶部开始 -->
<div class="container">
    <div class="logo" style=""><a href="left-menu-index.html">
        力鸿智信
        ${TitleName.indexTitle!"无结果"}
    </a></div>
    <div class="left_open">
        <i title="展开/关闭菜单栏" class="iconfont">&#xe699;</i>
    </div>
    <ul class="layui-nav right" lay-filter="">
        <li class="layui-nav-item">
            <a href="javascript:void(0);">${shiro.getUser().name}</a>
            <dl class="layui-nav-child"> <!-- 二级菜单 -->
                <dd>
                    <a onclick="x_admin_show('个人信息','${ctxPath}/userpermission/user/edit?id=${shiro.getUser().id}',500,260 )">个人信息</a>
                </dd>
                <dd><a onclick="x_admin_show('切换帐号','http://www.baidu.com')">切换帐号</a></dd>
                <dd><a href="${ctxPath}/login">退出</a></dd>
            </dl>
        </li>
        <!-- <li class="layui-nav-item to-index"><a href="/">前台首页</a></li>-->
    </ul>

</div>
<!-- 顶部结束 -->
<!-- 中部开始 -->
<!-- 左侧菜单开始 -->
<div class="left-nav">
    <ul id="navTree" class="ztree"></ul>
</div>

<!-- <div class="x-slide_left"></div> -->
<!-- 左侧菜单结束 -->
<!-- 右侧主体开始 -->
<div class="page-content">
    <div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="true">
        <ul class="layui-tab-title">
            <li class="home"><i class="layui-icon">&#xe68e;</i>首页</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <iframe src='' id="indexIframe" frameborder="0" scrolling="yes" class="x-iframe"></iframe>
            </div>
        </div>
    </div>
</div>
<div class="page-content-bg">

</div>
<!-- 右侧主体结束 -->
<!-- 中部结束 -->
<!-- 底部开始 -->
<div class="footer">
    <div class="copyright">Copyright ©2018 力鸿智信（北京）科技有限公司</div>
</div>
<!-- 底部结束 -->
<script>
    var menuTree;
    var setting = {
        check: {
            enable: true
        },
        data: {
            simpleData: {
                idKey: "id",
                pIdKey: "pid",
                enable: true
            },
            key: {
                name: "name",
                url: "url"
            },
            keep: {
                leaf: true,
                parent: true
            }
        },
        edit: {
            enable: true,
            showRenameBtn: false,
            showRemoveBtn: false
        },
        callback: {
            onClick: zTreeOnClick
        }
    };

    $(function () {
        $.cajax('${ctxPath}/ajax/userpermission/menu/indexMenuZtree', {}, function (r) {
            var code = r.code;
            var msg = r.msg;
            if (code == '1') {
                var menuNodes = r.datas;
                menuTree = $.fn.zTree.init($("#navTree"), setting, menuNodes);
            } else {
                $.msg(msg, function () {
                }, 2);
            }
        });
    });

    function zTreeOnClick(event, treeId, treeNode) {
        if (treeNode.url) {
            $('#indexIframe').attr('src', '${ctxPath}' + treeNode.url);
            indexMenusZtree(treeNode.name, treeNode.url, treeNode.id)
        }
    }

    function indexMenusZtree(title, url, index) {
        var layId = $('li[lay-id="' + index + '"]').attr('lay-id');

        //加载弹出层
        layui.use('element', function () {
            var element = layui.element;
            var tab = {
                tabAdd: function (title, url, id) {
                    //新增一个Tab项
                    element.tabAdd('xbs_tab', {
                        title: title
                        ,
                        content: '<iframe tab-id="' + id + '" frameborder="0" src="' + url + '" scrolling="yes" class="x-iframe"></iframe>'
                        ,
                        id: id
                    })
                }
                , tabDelete: function (othis) {
                    //删除指定Tab项
                    element.tabDelete('xbs_tab', layId);
                    othis.addClass('layui-btn-disabled');
                }
                , tabChange: function (id) {
                    //切换到指定Tab项
                    element.tabChange('xbs_tab', id);
                }
            };
            if (!layId) { //如果tab没有该菜单再添加
                tab.tabAdd(title, url, index);
                tab.tabChange(index);
            } else {
                tab.tabChange(index);
            }
            element.on('tabDelete(xbs_tab)', function (data) {
                var id = $(this).parent().attr('lay-id');
                var ifr = $('iframe[tab-id="' + id + '"]');
                ifr.parentNode.removeChild(ifr)
            });
        });
    }


</script>
<@>}